
import javax.swing.*;
import javax.swing.border.*;
import java.awt.*;
import java.awt.event.*;
import java.util.ArrayList;
import java.util.List;

/**
 * 几何图形计算与显示系统 - 修复版
 * 修复了图形名称显示问题
 */
public class GeometryApp {

    public static void main(String[] args) {
        System.out.println("启动几何图形计算与显示系统...");

        // 在事件分发线程中创建GUI
        SwingUtilities.invokeLater(new Runnable() {
            public void run() {
                createAndShowGUI();
            }
        });
    }

    private static void createAndShowGUI() {
        // 创建并设置主窗口
        JFrame frame = new JFrame("几何图形计算与显示系统");
        frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        frame.setLayout(new BorderLayout());

        // 创建图形显示面板
        ShapePanel shapePanel = new ShapePanel("图形显示");
        frame.add(shapePanel, BorderLayout.CENTER);

        // 创建信息面板
        JPanel infoPanel = createInfoPanel();
        frame.add(infoPanel, BorderLayout.EAST);

        // 创建按钮面板
        JPanel buttonPanel = createButtonPanel(shapePanel);
        frame.add(buttonPanel, BorderLayout.SOUTH);

        // 设置窗口属性并显示
        frame.setSize(1000, 600); // 设置更大的窗口尺寸
        frame.setLocationRelativeTo(null);
        frame.setVisible(true);
    }

    private static JPanel createInfoPanel() {
        JPanel panel = new JPanel(new BorderLayout());
        panel.setPreferredSize(new Dimension(300, 400));
        panel.setBorder(BorderFactory.createTitledBorder("图形信息"));

        JTextArea infoArea = new JTextArea();
        infoArea.setEditable(false);
        infoArea.setFont(new Font("宋体", Font.PLAIN, 12));
        infoArea.setLineWrap(true);
        infoArea.setWrapStyleWord(true);
        infoArea.setText("请点击\"生成图形\"按钮显示图形...");

        JScrollPane scrollPane = new JScrollPane(infoArea);
        panel.add(scrollPane, BorderLayout.CENTER);

        // 保存infoArea的引用以便后续使用
        MainAppInfo.infoArea = infoArea;

        return panel;
    }

    private static JPanel createButtonPanel(ShapePanel shapePanel) {
        JPanel panel = new JPanel(new FlowLayout());

        JButton calculateButton = new JButton("生成图形");
        JButton clearButton = new JButton("清空显示");
        JButton testButton = new JButton("运行测试");

        // 设置按钮事件
        calculateButton.addActionListener(new ActionListener() {
            public void actionPerformed(ActionEvent e) {
                generateShapes(shapePanel);
            }
        });

        clearButton.addActionListener(new ActionListener() {
            public void actionPerformed(ActionEvent e) {
                shapePanel.clearShapes();
                MainAppInfo.infoArea.setText("请点击\"生成图形\"按钮显示图形...");
            }
        });

        testButton.addActionListener(new ActionListener() {
            public void actionPerformed(ActionEvent e) {
                GeometryTest.runTests();
            }
        });

        panel.add(calculateButton);
        panel.add(clearButton);
        panel.add(testButton);

        return panel;
    }

    private static void generateShapes(ShapePanel shapePanel) {
        // 清空现有显示
        shapePanel.clearShapes();
        MainAppInfo.infoArea.setText("");

        // 创建各种图形
        Shape[] shapes = {
                new Rectangle(6, 4),
                new Square(5),
                new Triangle(6, 4, 5, 5),
                new Circle(3),
                new Diamond(6, 8),
                new Pentagon(4)
        };

        // 添加图形到面板并显示信息
        StringBuilder info = new StringBuilder();
        info.append("=== 几何图形信息 ===\n\n");

        double totalArea = 0;
        double totalPerimeter = 0;

        for (Shape shape : shapes) {
            shapePanel.addShape(shape);

            info.append(shape.toString()).append("\n");

            totalArea += shape.calculateArea();
            totalPerimeter += shape.calculatePerimeter();
        }

        // 添加统计信息
        info.append("=== 统计信息 ===\n");
        info.append(String.format("图形总数: %d\n", shapes.length));
        info.append(String.format("总面积: %.2f\n", totalArea));
        info.append(String.format("总周长: %.2f", totalPerimeter));

        MainAppInfo.infoArea.setText(info.toString());
    }

    private static String getColorName(Color color) {
        if (color.equals(Color.RED)) return "红色";
        if (color.equals(Color.BLUE)) return "蓝色";
        if (color.equals(Color.GREEN)) return "绿色";
        if (color.equals(Color.ORANGE)) return "橙色";
        if (color.equals(Color.MAGENTA)) return "洋红色";
        if (color.equals(Color.CYAN)) return "青色";
        if (color.equals(Color.PINK)) return "粉色";
        if (color.equals(Color.YELLOW)) return "黄色";
        return "";
    }
}

/**
 * 存储应用程序信息的类
 */
class MainAppInfo {
    public static JTextArea infoArea;
}

/**
 * 图形绘制面板 - 修复名称显示问题
 */
class ShapePanel extends JPanel {
    private List<Shape> shapes;
    private String title;

    public ShapePanel(String title) {
        this.shapes = new ArrayList<>();
        this.title = title;
        setPreferredSize(new Dimension(700, 500)); // 增加面板尺寸
        setBackground(Color.WHITE);
        setBorder(BorderFactory.createTitledBorder(title));
    }

    public void addShape(Shape shape) {
        shapes.add(shape);
        repaint();
    }

    public void clearShapes() {
        shapes.clear();
        repaint();
    }

    @Override
    protected void paintComponent(Graphics g) {
        super.paintComponent(g);
        Graphics2D g2d = (Graphics2D) g;

        // 启用抗锯齿
        g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING,
                RenderingHints.VALUE_ANTIALIAS_ON);

        if (shapes.isEmpty()) {
            // 如果没有图形，显示提示信息
            g2d.setColor(Color.GRAY);
            g2d.setFont(new Font("宋体", Font.BOLD, 16));
            String message = "点击\"生成图形\"按钮显示几何图形";
            FontMetrics fm = g2d.getFontMetrics();
            int x = (getWidth() - fm.stringWidth(message)) / 2;
            int y = getHeight() / 2;
            g2d.drawString(message, x, y);
            return;
        }

        // 计算每个图形的位置 - 修复布局计算
        int cols = 3; // 每行显示3个图形
        int totalShapes = shapes.size();
        int rows = (int) Math.ceil(totalShapes / (double) cols);

        // 计算每个图形区域的大小
        int availableWidth = getWidth() - 40; // 左右边距
        int availableHeight = getHeight() - 60; // 上下边距，为名称留出空间

        int cellWidth = availableWidth / cols;
        int cellHeight = availableHeight / rows;
        int shapeSize = Math.min(cellWidth, cellHeight) - 20; // 图形实际绘制大小

        for (int i = 0; i < totalShapes; i++) {
            int row = i / cols;
            int col = i % cols;

            // 计算图形中心点坐标
            int centerX = 20 + col * cellWidth + cellWidth / 2;
            int centerY = 30 + row * cellHeight + cellHeight / 2;

            // 绘制图形
            shapes.get(i).draw(g2d, centerX, centerY, shapeSize);

            // 绘制图形名称 - 修复名称位置计算
            g2d.setColor(Color.BLACK);
            g2d.setFont(new Font("宋体", Font.BOLD, 14));
            String name = shapes.get(i).getName();
            FontMetrics fm = g2d.getFontMetrics();
            int nameWidth = fm.stringWidth(name);
            int nameX = centerX - nameWidth / 2;
            int nameY = centerY + shapeSize / 2 + 30; // 在图形下方留出足够空间

            // 确保名称在可见区域内
            if (nameY < getHeight() - 10) {
                g2d.drawString(name, nameX, nameY);
            }
        }
    }
}

/**
 * 图形抽象基类
 */
abstract class Shape {
    protected String name;
    protected Color color;

    public Shape(String name) {
        this.name = name;
        this.color = getRandomColor();
    }

    // 抽象方法：子类必须实现
    public abstract double calculateArea();
    public abstract double calculatePerimeter();
    public abstract void draw(Graphics2D g2d, int x, int y, int size);

    // 具体方法：所有子类共享
    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public Color getColor() {
        return color;
    }

    public void setColor(Color color) {
        this.color = color;
    }

    @Override
    public String toString() {
        return String.format("图形: %s, 面积: %.2f, 周长: %.2f",
                name, calculateArea(), calculatePerimeter());
    }

    // 生成随机颜色
    protected Color getRandomColor() {
        Color[] colors = {
                new Color(255, 100, 100),    // 浅红
                new Color(100, 100, 255),    // 浅蓝
                new Color(100, 200, 100),    // 浅绿
                new Color(255, 200, 100),    // 橙色
                new Color(200, 100, 255),    // 紫色
                new Color(100, 255, 255),    // 青色
                new Color(255, 100, 200),    // 粉色
                new Color(255, 255, 100)     // 黄色
        };
        return colors[(int) (Math.random() * colors.length)];
    }
}

/**
 * 圆形类
 */
class Circle extends Shape {
    private double radius;

    public Circle(double radius) {
        super("圆形");
        setRadius(radius);
    }

    @Override
    public double calculateArea() {
        return Math.PI * radius * radius;
    }

    @Override
    public double calculatePerimeter() {
        return 2 * Math.PI * radius;
    }

    @Override
    public void draw(Graphics2D g2d, int x, int y, int size) {
        int drawRadius = (int) (size * 0.4);

        // 设置绘制属性
        g2d.setColor(color);
        g2d.setStroke(new BasicStroke(3));

        // 绘制填充圆形
        g2d.fillOval(x - drawRadius, y - drawRadius, drawRadius * 2, drawRadius * 2);

        // 绘制边框
        g2d.setColor(Color.BLACK);
        g2d.drawOval(x - drawRadius, y - drawRadius, drawRadius * 2, drawRadius * 2);

        // 绘制半径线
        g2d.setColor(new Color(0, 0, 0, 150));
        g2d.setStroke(new BasicStroke(2));
        g2d.drawLine(x, y, x + drawRadius, y);

        // 绘制半径标注
        g2d.setColor(Color.BLUE);
        g2d.setFont(new Font("宋体", Font.PLAIN, 10));
        g2d.drawString("r=" + radius, x + drawRadius / 2, y - 5);
    }

    public double getRadius() {
        return radius;
    }

    public void setRadius(double radius) {
        if (radius <= 0) {
            throw new IllegalArgumentException("半径必须大于0");
        }
        this.radius = radius;
    }
}

/**
 * 矩形类
 */
class Rectangle extends Shape {
    private double width;
    private double height;

    public Rectangle(double width, double height) {
        super("矩形");
        setWidth(width);
        setHeight(height);
    }

    @Override
    public double calculateArea() {
        return width * height;
    }

    @Override
    public double calculatePerimeter() {
        return 2 * (width + height);
    }

    @Override
    public void draw(Graphics2D g2d, int x, int y, int size) {
        // 根据宽高比例计算绘制尺寸
        double ratio = width / height;
        int drawWidth, drawHeight;

        if (ratio > 1) {
            drawWidth = (int) (size * 0.8);
            drawHeight = (int) (drawWidth / ratio);
        } else {
            drawHeight = (int) (size * 0.8);
            drawWidth = (int) (drawHeight * ratio);
        }

        int startX = x - drawWidth / 2;
        int startY = y - drawHeight / 2;

        // 设置绘制属性
        g2d.setColor(color);
        g2d.setStroke(new BasicStroke(3));

        // 绘制填充矩形
        g2d.fillRect(startX, startY, drawWidth, drawHeight);

        // 绘制边框
        g2d.setColor(Color.BLACK);
        g2d.drawRect(startX, startY, drawWidth, drawHeight);

        // 绘制尺寸标注
        g2d.setColor(Color.BLUE);
        g2d.setFont(new Font("宋体", Font.PLAIN, 10));
        g2d.drawString("w=" + width, startX + drawWidth / 2 - 15, startY - 5);
        g2d.drawString("h=" + height, startX - 25, startY + drawHeight / 2);
    }

    public double getWidth() {
        return width;
    }

    public void setWidth(double width) {
        if (width <= 0) {
            throw new IllegalArgumentException("宽度必须大于0");
        }
        this.width = width;
    }

    public double getHeight() {
        return height;
    }

    public void setHeight(double height) {
        if (height <= 0) {
            throw new IllegalArgumentException("高度必须大于0");
        }
        this.height = height;
    }
}

/**
 * 正方形类 - 继承自矩形
 */
class Square extends Rectangle {

    public Square(double side) {
        super(side, side);
        setName("正方形");
    }

    @Override
    public void draw(Graphics2D g2d, int x, int y, int size) {
        int drawSize = (int) (size * 0.7);
        int startX = x - drawSize / 2;
        int startY = y - drawSize / 2;

        // 设置绘制属性
        g2d.setColor(getColor());
        g2d.setStroke(new BasicStroke(3));

        // 绘制填充正方形
        g2d.fillRect(startX, startY, drawSize, drawSize);

        // 绘制边框
        g2d.setColor(Color.BLACK);
        g2d.drawRect(startX, startY, drawSize, drawSize);

        // 绘制边长标注
        g2d.setColor(Color.BLUE);
        g2d.setFont(new Font("宋体", Font.PLAIN, 10));
        g2d.drawString("a=" + getSide(), startX + drawSize / 2 - 15, startY - 5);

        // 绘制对角线
        g2d.setColor(new Color(0, 0, 0, 100));
        g2d.setStroke(new BasicStroke(1));
        g2d.drawLine(startX, startY, startX + drawSize, startY + drawSize);
        g2d.drawLine(startX + drawSize, startY, startX, startY + drawSize);
    }

    public double getSide() {
        return getWidth();
    }

    public void setSide(double side) {
        setWidth(side);
        setHeight(side);
    }
}

/**
 * 三角形类 - 等腰三角形
 */
class Triangle extends Shape {
    private double base;
    private double height;
    private double sideA;
    private double sideB;

    public Triangle(double base, double height, double sideA, double sideB) {
        super("三角形");
        setBase(base);
        setHeight(height);
        setSideA(sideA);
        setSideB(sideB);
    }

    @Override
    public double calculateArea() {
        return (base * height) / 2;
    }

    @Override
    public double calculatePerimeter() {
        return sideA + sideB + base;
    }

    @Override
    public void draw(Graphics2D g2d, int x, int y, int size) {
        int drawHeight = (int) (size * 0.6);
        int drawBase = (int) (drawHeight * (base / height));

        // 计算三角形的三个顶点
        int[] xPoints = {
                x,                    // 顶点
                x - drawBase / 2,     // 左下角
                x + drawBase / 2      // 右下角
        };

        int[] yPoints = {
                y - drawHeight / 2,   // 顶点
                y + drawHeight / 2,   // 左下角
                y + drawHeight / 2    // 右下角
        };

        // 设置绘制属性
        g2d.setColor(color);
        g2d.setStroke(new BasicStroke(3));

        // 绘制填充三角形
        g2d.fillPolygon(xPoints, yPoints, 3);

        // 绘制边框
        g2d.setColor(Color.BLACK);
        g2d.drawPolygon(xPoints, yPoints, 3);

        // 绘制高度线
        g2d.setColor(new Color(255, 255, 255, 200));
        g2d.setStroke(new BasicStroke(2));
        g2d.drawLine(x, y - drawHeight / 2, x, y + drawHeight / 2);

        // 绘制尺寸标注
        g2d.setColor(Color.BLUE);
        g2d.setFont(new Font("宋体", Font.PLAIN, 10));
        g2d.drawString("底=" + base, x - 15, y + drawHeight / 2 + 15);
        g2d.drawString("高=" + height, x + 5, y);
    }

    public double getBase() {
        return base;
    }

    public void setBase(double base) {
        if (base <= 0) {
            throw new IllegalArgumentException("底边必须大于0");
        }
        this.base = base;
    }

    public double getHeight() {
        return height;
    }

    public void setHeight(double height) {
        if (height <= 0) {
            throw new IllegalArgumentException("高度必须大于0");
        }
        this.height = height;
    }

    public double getSideA() {
        return sideA;
    }

    public void setSideA(double sideA) {
        if (sideA <= 0) {
            throw new IllegalArgumentException("边长必须大于0");
        }
        this.sideA = sideA;
    }

    public double getSideB() {
        return sideB;
    }

    public void setSideB(double sideB) {
        if (sideB <= 0) {
            throw new IllegalArgumentException("边长必须大于0");
        }
        this.sideB = sideB;
    }
}

/**
 * 菱形类
 */
class Diamond extends Shape {
    private double diagonal1;
    private double diagonal2;

    public Diamond(double diagonal1, double diagonal2) {
        super("菱形");
        setDiagonals(diagonal1, diagonal2);
    }

    @Override
    public double calculateArea() {
        return (diagonal1 * diagonal2) / 2;
    }

    @Override
    public double calculatePerimeter() {
        double side = Math.sqrt(Math.pow(diagonal1/2, 2) + Math.pow(diagonal2/2, 2));
        return 4 * side;
    }

    @Override
    public void draw(Graphics2D g2d, int x, int y, int size) {
        int drawD1 = (int) (size * 0.6);
        int drawD2 = (int) (drawD1 * (diagonal2 / diagonal1));

        // 计算菱形的四个顶点
        int[] xPoints = {
                x,              // 右顶点
                x + drawD1 / 2, // 上顶点
                x,              // 左顶点
                x - drawD1 / 2  // 下顶点
        };

        int[] yPoints = {
                y + drawD2 / 2, // 右顶点
                y,              // 上顶点
                y - drawD2 / 2, // 左顶点
                y               // 下顶点
        };

        // 设置绘制属性
        g2d.setColor(color);
        g2d.setStroke(new BasicStroke(3));

        // 绘制填充菱形
        g2d.fillPolygon(xPoints, yPoints, 4);

        // 绘制边框
        g2d.setColor(Color.BLACK);
        g2d.drawPolygon(xPoints, yPoints, 4);

        // 绘制对角线
        g2d.setColor(new Color(255, 255, 255, 200));
        g2d.setStroke(new BasicStroke(2));
        g2d.drawLine(x - drawD1 / 2, y, x + drawD1 / 2, y);
        g2d.drawLine(x, y - drawD2 / 2, x, y + drawD2 / 2);

        // 绘制尺寸标注
        g2d.setColor(Color.BLUE);
        g2d.setFont(new Font("宋体", Font.PLAIN, 10));
        g2d.drawString("d1=" + diagonal1, x + 5, y);
        g2d.drawString("d2=" + diagonal2, x - 25, y - drawD2 / 4);
    }

    public void setDiagonals(double d1, double d2) {
        if (d1 <= 0 || d2 <= 0) {
            throw new IllegalArgumentException("对角线长度必须大于0");
        }
        this.diagonal1 = d1;
        this.diagonal2 = d2;
    }

    public double getDiagonal1() {
        return diagonal1;
    }

    public double getDiagonal2() {
        return diagonal2;
    }
}

/**
 * 五边形类 - 正五边形
 */
class Pentagon extends Shape {
    private double side;

    public Pentagon(double side) {
        super("五边形");
        setSide(side);
    }

    @Override
    public double calculateArea() {
        // 正五边形面积公式: (5 * s^2) / (4 * tan(π/5))
        return (5 * side * side) / (4 * Math.tan(Math.PI / 5));
    }

    @Override
    public double calculatePerimeter() {
        return 5 * side;
    }

    @Override
    public void draw(Graphics2D g2d, int x, int y, int size) {
        int radius = (int) (size * 0.4);

        // 计算正五边形的五个顶点
        int[] xPoints = new int[5];
        int[] yPoints = new int[5];

        for (int i = 0; i < 5; i++) {
            double angle = 2 * Math.PI * i / 5 - Math.PI / 2; // 从顶部开始
            xPoints[i] = x + (int) (radius * Math.cos(angle));
            yPoints[i] = y + (int) (radius * Math.sin(angle));
        }

        // 设置绘制属性
        g2d.setColor(color);
        g2d.setStroke(new BasicStroke(3));

        // 绘制填充五边形
        g2d.fillPolygon(xPoints, yPoints, 5);

        // 绘制边框
        g2d.setColor(Color.BLACK);
        g2d.drawPolygon(xPoints, yPoints, 5);

        // 绘制中心到顶点的线
        g2d.setColor(new Color(255, 255, 255, 150));
        g2d.setStroke(new BasicStroke(1));
        for (int i = 0; i < 5; i++) {
            g2d.drawLine(x, y, xPoints[i], yPoints[i]);
        }

        // 绘制边长标注
        g2d.setColor(Color.BLUE);
        g2d.setFont(new Font("宋体", Font.PLAIN, 10));
        g2d.drawString("a=" + side, x - 10, y - radius - 5);
    }

    public double getSide() {
        return side;
    }

    public void setSide(double side) {
        if (side <= 0) {
            throw new IllegalArgumentException("边长必须大于0");
        }
        this.side = side;
    }
}

/**
 * 单元测试类
 */
class GeometryTest {

    public static void runTests() {
        System.out.println("=== 开始单元测试 ===");

        testCircle();
        testRectangle();
        testSquare();
        testTriangle();
        testDiamond();
        testPentagon();

        System.out.println("=== 单元测试完成 ===");

        // 在控制台显示测试完成提示
        JOptionPane.showMessageDialog(null,
                "单元测试完成！请查看控制台输出。",
                "测试完成",
                JOptionPane.INFORMATION_MESSAGE);
    }

    private static void testCircle() {
        try {
            Circle circle = new Circle(5);
            double area = circle.calculateArea();
            double perimeter = circle.calculatePerimeter();
            if (Math.abs(area - Math.PI * 25) < 0.001 &&
                    Math.abs(perimeter - 2 * Math.PI * 5) < 0.001) {
                System.out.println("✓ 圆形测试通过 - 面积: " + area + ", 周长: " + perimeter);
            } else {
                System.out.println("✗ 圆形测试失败");
            }
        } catch (Exception e) {
            System.out.println("✗ 圆形测试失败: " + e.getMessage());
        }
    }

    private static void testRectangle() {
        try {
            Rectangle rect = new Rectangle(4, 5);
            double area = rect.calculateArea();
            double perimeter = rect.calculatePerimeter();
            if (area == 20 && perimeter == 18) {
                System.out.println("✓ 矩形测试通过 - 面积: " + area + ", 周长: " + perimeter);
            } else {
                System.out.println("✗ 矩形测试失败");
            }
        } catch (Exception e) {
            System.out.println("✗ 矩形测试失败: " + e.getMessage());
        }
    }

    private static void testSquare() {
        try {
            Square square = new Square(5);
            double area = square.calculateArea();
            double perimeter = square.calculatePerimeter();
            if (area == 25 && perimeter == 20) {
                System.out.println("✓ 正方形测试通过 - 面积: " + area + ", 周长: " + perimeter);
            } else {
                System.out.println("✗ 正方形测试失败");
            }
        } catch (Exception e) {
            System.out.println("✗ 正方形测试失败: " + e.getMessage());
        }
    }

    private static void testTriangle() {
        try {
            Triangle triangle = new Triangle(6, 4, 5, 5);
            double area = triangle.calculateArea();
            double perimeter = triangle.calculatePerimeter();
            if (area == 12 && perimeter == 16) {
                System.out.println("✓ 三角形测试通过 - 面积: " + area + ", 周长: " + perimeter);
            } else {
                System.out.println("✗ 三角形测试失败");
            }
        } catch (Exception e) {
            System.out.println("✗ 三角形测试失败: " + e.getMessage());
        }
    }

    private static void testDiamond() {
        try {
            Diamond diamond = new Diamond(6, 8);
            double area = diamond.calculateArea();
            double perimeter = diamond.calculatePerimeter();
            if (area == 24 && Math.abs(perimeter - 20) < 0.001) {
                System.out.println("✓ 菱形测试通过 - 面积: " + area + ", 周长: " + perimeter);
            } else {
                System.out.println("✗ 菱形测试失败");
            }
        } catch (Exception e) {
            System.out.println("✗ 菱形测试失败: " + e.getMessage());
        }
    }

    private static void testPentagon() {
        try {
            Pentagon pentagon = new Pentagon(4);
            double area = pentagon.calculateArea();
            double perimeter = pentagon.calculatePerimeter();
            double expectedArea = (5 * 16) / (4 * Math.tan(Math.PI / 5));
            if (Math.abs(area - expectedArea) < 0.001 && perimeter == 20) {
                System.out.println("✓ 五边形测试通过 - 面积: " + area + ", 周长: " + perimeter);
            } else {
                System.out.println("✗ 五边形测试失败");
            }
        } catch (Exception e) {
            System.out.println("✗ 五边形测试失败: " + e.getMessage());
        }
    }
}